package study.couse04;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class UseThreadPoolState {
    static volatile Integer res = null;

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(1);
        service.execute(new Sub());
        service.shutdown();
        while (!service.isTerminated()) {
            Thread.sleep(10);
        }
        System.out.println("子线程结果:" + res);
    }

    static class Sub implements Runnable {

        @Override
        public void run() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            res = 1;
        }
    }
}

